/**
* Created by Administrator on 2025/5/7.
* */
#include "AppDelegate.h"
#include "GlobalParameters.h"
#include <string>
#include "DataRepository/DataRepository.h"
#include "MyDeviceReader/MyDeviceReader.h"
#include "MyDeviceWriter/MyDeviceWriter.h"
#include "MyDeviceReader_2/MyDeviceReader_2.h"
#include "EthernetWriter.h"

void AppDelegate::onConfigure(device_config_t *config){
    config->calculationPoolSize=8;
    config->globalParametersInstance = GlobalParameters::shareInstance();
    config->deviceId=5;
    config->servicePort=55261;
    config->ip="192.168.1.115";
    config->userVersion="1.0";
}

void AppDelegate::onStart(){
    REGISTER_RUNTIME_LOADED_CLASSES(DataRepository,MyDeviceReader,MyDeviceReader_2,MyDeviceWriter);
    auto dataRepository = new DataRepository();

    auto radarlabReader = new MyDeviceReader();
    radarlabReader->addTaskModule(dataRepository,0,1024);

    auto radarlabReader_1 = new MyDeviceReader();
    radarlabReader_1->addTaskModule(dataRepository,1,1024);

    auto radarlabReader_2 = new MyDeviceReader_2();
    radarlabReader_2->addTaskModule(dataRepository,2,1024);

    dataRepository->setLaunchPolicy(LaunchMode_OR,LaunchCondition());

    auto radarlabWriter = new MyDeviceWriter();
    dataRepository->addDeviceWriter(0,radarlabWriter,1024);

    auto radarlabWriter_1 = new EthernetWriter(TCP,"192.168.1.115",6672,true);
    dataRepository->addDeviceWriter(1,radarlabWriter_1,1024);

    auto radarlabWriter_2 = new EthernetWriter(TCP,"192.168.1.115",6673,true);
    dataRepository->addDeviceWriter(2,radarlabWriter_2,1024);

    auto radarlabWriter_3 = new EthernetWriter(TCP,"192.168.1.115",6674,true);
    dataRepository->addDeviceWriter(3,radarlabWriter_3,1024);
    REGISTER_INSTANCES(dataRepository,radarlabReader,radarlabReader_1,radarlabReader_2,radarlabWriter,radarlabWriter_1,radarlabWriter_2,radarlabWriter_3);
}
